from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from .test_routes import test_router
from .login import login_router
from .register import register_router
from .forgot_password import forgot_password_route
from .bill import bill_router
from .user_setting import user_setting_router
from .home import home_router
from .budget import budget_router
from .notification import notification_router
from .family import family_router


def create_app():
    app = FastAPI()
    
    app.add_middleware(
        CORSMiddleware,
        allow_origins=["http://localhost:5173"],
        allow_credentials=True,
        allow_methods=["*"],
        allow_headers=["*"],
    )

    app.include_router(test_router)
    app.include_router(login_router)
    app.include_router(register_router)
    app.include_router(forgot_password_route)
    app.include_router(bill_router)
    app.include_router(user_setting_router)
    app.include_router(home_router)
    app.include_router(budget_router)
    app.include_router(notification_router)
    app.include_router(family_router)

    return app
